﻿<%@ Page Language="C#" MasterPageFile="~/WebSite/manager.Master" AutoEventWireup="true" CodeFile="m_news_check.aspx.cs" Inherits="WebSite_m_news_check" Title="新闻管理" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder2" Runat="Server">
<style type="text/css">
    .TitleStyle
    {
        margin-top:10px;
        margin-left:30px;
        width:400px;
        height:60px;
    }
    .TitleStyle h1
    {
    	margin-top:0px;
    	background-image:url(../images/Pad.png);
        background-repeat:no-repeat;
        font-size:20px;
        width:400px;
        height:50px;
        padding-top:15px;
        padding-left:50px;
    }
    .AddStyle
    {
    	margin-top:15px;
    	margin-bottom:15px;
    	margin-left:270px;
    	width:90px;
    	height:30px;
    	background-color:#669DF0;
    	font-size:16px;
    	font-weight:bold;
    	color:#FFFFFF;
    }
</style>
<div class="TitleStyle">
    <h1>新闻管理后台</h1>
</div>
<asp:GridView ID="NewsGridView" runat="server" AllowPaging="True" 
        AllowSorting="True" AutoGenerateColumns="False" DataKeyNames="Id" 
        DataSourceID="SqlDataSource1" CellPadding="4" ForeColor="#333333" 
        GridLines="None"  OnRowDataBound="NewsGridView_RowDataBound" >
    <RowStyle BackColor="#EFF3FB" />
    <Columns>
        <asp:BoundField DataField="Id" HeaderText="文章编号" ReadOnly="True" 
            SortExpression="Id" />
        <asp:TemplateField HeaderText="标题">
            <ItemTemplate>
                <asp:HyperLink ID="HyperLink1" Text='<%#Eval("Title")%>' runat="server" NavigateUrl='<%# "~/WebSite/m_news_edit.aspx?" %>' >
                </asp:HyperLink>
            </ItemTemplate>
        </asp:TemplateField>
        <asp:BoundField DataField="Section" HeaderText="文章类别" 
            SortExpression="Section" />
        <asp:BoundField DataField="UserId" HeaderText="用户id" SortExpression="UserId" />
        <asp:BoundField DataField="ItemDate" HeaderText="编辑时间" 
            SortExpression="ItemDate" />
        <asp:CommandField ShowDeleteButton="True" />
    </Columns>
    <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
    <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
    <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
    <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
    <EditRowStyle BackColor="#2461BF" />
    <AlternatingRowStyle BackColor="White" />
</asp:GridView>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
        ConnectionString="<%$ ConnectionStrings:CSHDBConnectionString %>" 
        
        
        SelectCommand="SELECT [Id], [Section], [Title], [UserId], [ItemDate] FROM [News]" 
        DeleteCommand="DELETE FROM [News] WHERE [Id] = @Id" 
        InsertCommand="INSERT INTO [News] ([Id], [Section], [Title], [UserId], [ItemDate]) VALUES (@Id, @Section, @Title, @UserId, @ItemDate)" 
        UpdateCommand="UPDATE [News] SET [Section] = @Section, [Title] = @Title, [UserId] = @UserId, [ItemDate] = @ItemDate WHERE [Id] = @Id">
        <DeleteParameters>
            <asp:Parameter Name="Id" Type="Int32" />
        </DeleteParameters>
        <UpdateParameters>
            <asp:Parameter Name="Section" Type="Int32" />
            <asp:Parameter Name="Title" Type="String" />
            <asp:Parameter Name="UserId" Type="String" />
            <asp:Parameter DbType="Date" Name="ItemDate" />
            <asp:Parameter Name="Id" Type="Int32" />
        </UpdateParameters>
        <InsertParameters>
            <asp:Parameter Name="Id" Type="Int32" />
            <asp:Parameter Name="Section" Type="Int32" />
            <asp:Parameter Name="Title" Type="String" />
            <asp:Parameter Name="UserId" Type="String" />
            <asp:Parameter DbType="Date" Name="ItemDate" />
        </InsertParameters>
    </asp:SqlDataSource>
    <asp:Button Id="AddNewsBtn" runat="server" CssClass="AddStyle" Text="添加文章" 
        onclick="AddNewsBtn_Click"/>
</asp:Content>

